package com.sali.b_design_pattern.j_builder_pattern.lesson_02;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Serializable;

/**
 * @description:
 * @author: zhang hang
 * @date: 2023/3/18 23:10.
 * @version: 1.0
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class User implements Serializable {

    private Long id;
    private String username;
    private String password;
    private Integer age;
    private String address;

    public static User.UserBuilder builder() {
        return new User.UserBuilder();
    }

    static class UserBuilder {
        private Long id;
        private String username;
        private String password;
        private Integer age;
        private String address;

        public UserBuilder id(Long id) {
            this.id = id;
            return this;
        }

        public UserBuilder username(String username) {
            this.username = username;
            return this;
        }

        public UserBuilder password(String password) {
            this.password = password;
            return this;
        }

        public UserBuilder age(Integer age) {
            this.age = age;
            return this;
        }

        public UserBuilder address(String address) {
            this.address = address;
            return this;
        }

        public User build() {
            return new User(this.id, this.username, this.password, this.age, this.address);
        }
    }

}
